package com.ysd.lis.controller;


import com.ysd.common.Result;
import com.ysd.lis.annotation.LogDetail;
import com.ysd.lis.aspect.OperationType;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.WkQualityPlan;
import com.ysd.lis.request.QualityPlanListParams;
import com.ysd.lis.service.WkQualityPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 质量控制计划表 前端控制器
 * </p>
 *
 * @author LiuQi
 * @since 2024-05-06
 */
@RestController
@RequestMapping("/wk/quality/plan")
public class WkQualityPlanController extends BaseController {

    @Autowired
    WkQualityPlanService wkQualityPlanService;

    @GetMapping("/getQualityPlanList")
    public Result getQualityPlanList(QualityPlanListParams qualityPlanListParams) {
        return wkQualityPlanService.getQualityPlanList(qualityPlanListParams);
    }

    @PostMapping("/addQualityPlan")
    @LogDetail(requestParam = "addQualityPlan", operationType = OperationType.INSERT, module = "绩效考核-质量控制计划表", content = "新增【qualityPlan】计划", businessName = "qualityPlan")
    public Result addQualityPlan(@RequestBody WkQualityPlan wkQualityPlan) {
        return wkQualityPlanService.addQualityPlan(wkQualityPlan);
    }

    @PostMapping("/editQualityPlan")
    @LogDetail(requestParam = "update", operationType = OperationType.UPDATE, module = "绩效考核-质量控制计划表", content = "编辑", businessName = "qualityPlan")
    public Result editQualityPlan(@RequestBody WkQualityPlan wkQualityPlan) {
        return wkQualityPlanService.editQualityPlan(wkQualityPlan);
    }

    @PostMapping("/deleteQualityPlan")
    @LogDetail(requestParam = "delete", operationType = OperationType.DELETE, module = "绩效考核-质量控制计划表", content = "删除", businessName = "qualityPlan")
    public Result deleteQualityPlan(@RequestBody List<String> ids) {
        return wkQualityPlanService.deleteQualityPlan(ids);
    }

    @PostMapping("/updatePlanStatus")
    @LogDetail(requestParam = "updatePlanStatus", operationType = OperationType.UPDATE, module = "绩效考核-质量控制计划表", content = "编辑了【qualityPlan】", businessName = "qualityPlan")
    public Result updatePlanStatus(@RequestBody WkQualityPlan wkQualityPlan) {
        return wkQualityPlanService.updatePlanStatus(wkQualityPlan.getPlanStatus(), wkQualityPlan.getId());
    }
}
